package cn.net.bhb.base.base;


import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.hannesdorfmann.mosby3.mvp.MvpFragment;
import com.hannesdorfmann.mosby3.mvp.MvpPresenter;
import com.hannesdorfmann.mosby3.mvp.MvpView;
import com.jaeger.library.StatusBarUtil;

import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;

/**
 * 所有的Fragment继承此类
 */
public abstract class BaseFragment<V extends MvpView, P extends MvpPresenter<V>> extends MvpFragment<V, P> {
//    private Unbinder bind;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View view = inflater.inflate(getLayoutId(), container, false);

//        bind = ButterKnife.bind(this, view);
        initView();
        initListener();

        return view;
    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        initData();
    }

    public abstract int getLayoutId();

    protected abstract void initView();

    protected abstract void initData();

    protected abstract void initListener();

    public void setStatusBarColor(int color) {
        StatusBarUtil.setLightMode(getActivity());
        StatusBarUtil.setColorNoTranslucent(getActivity(), ContextCompat.getColor(getActivity(), color));
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        // 注销
//        bind.unbind();
    }

}
